package services;

import domain.entities.DoctorDegreeDAO;
import domain.entities.DoctorDegree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Guillermo
 * Date: 22/08/12
 * Time: 15:30
 * To change this template use File | Settings | File Templates.
 */
@Service
public class DoctorDegreeService {

    private DoctorDegreeDAO doctorDegreeDAO;

    public DoctorDegreeService() {
    }

    @Autowired
    public DoctorDegreeService(DoctorDegreeDAO doctorDegreeDAO) {
        this.doctorDegreeDAO = doctorDegreeDAO;
    }

    public List<DoctorDegree> findAll(){
        return doctorDegreeDAO.findAll();
    }

    public DoctorDegree findbyId(Integer id){
        return doctorDegreeDAO.findById(id);
    }
    public DoctorDegree findByDescripcion(String descripcion){
        return doctorDegreeDAO.findByDescripcion(descripcion);
    }

    public void checkType(String descripcion){
        if (!descripcion.equals("") && !doctorDegreeDAO.existByDescripcion(descripcion)){
            doctorDegreeDAO.attachDirty(new DoctorDegree(descripcion));
        }
        return ;
    }
}
